import java.util.Arrays;

public class MyStack {
    private int[] elem;
    private int usedSize;

    private static final int DEFAULT_CAPACITY=10;

    public MyStack(int[] elem) {
        this.elem = elem;
    }
public boolean isFull(){

        return usedSize==elem.length;
}
  //添加元素
    public void push(int val){
        if (isFull()){
            elem= Arrays.copyOf(elem,2*elem.length);
            elem[usedSize]=val;
            usedSize++;
        }

    }

public int pop(){
      if (isEmpty()) {
          System.out.println("空");
      }
      int oldVal=elem[usedSize-1];
      usedSize--;
      return oldVal;
}
   public int peek() {
      return elem[usedSize-1];
   }
  public boolean isEmpty(){
        return usedSize==0;
  }

    
}
